< previous page page_308 next page >

Page 308
This example will give you a hands-on understanding of the issues involved in developing ActiveX controls in the Visual Basic IDE. The AddressCtl control will be built entirely of existing Label and TextBox controls. First, you will draw the user interface of the control and then add minimal code to make it work in the VB design environment.
To build the Address control, follow these steps:
1. Start Visual Basic 6.0. If it is already running, choose File, New Project.
2. From the New Project dialog box, select ActiveX Control. A new project is created with a UserControl object named UserControl1, as shown in Figure 14.1.
0308-01.jpg
Figure 14.1
A UserControl object is similar to a form but
has no borders or standard window elements.
3. Change the name of the UserControl object to AddressCtl in the Properties window.
4. Choose Project, Project1 Properties. The Project1 Properties dialog box appears.
5. In the Project Name text box, change the name of the project (Project1) to something meaningful, such as Address.
textbox.gif6. Add five TextBox controls to the form. Set the values of their Text properties to empty strings, and give them the following names:
d6ef40187df115e88326dbc94f09ab9a.gif
txtName
d6ef40187df115e88326dbc94f09ab9a.gif
txtStreet
d6ef40187df115e88326dbc94f09ab9a.gif
txtCity
d6ef40187df115e88326dbc94f09ab9a.gif
txtState
d6ef40187df115e88326dbc94f09ab9a.gif
txtZip
7. Add five Label controls to the form and give them the following properties:
Name Property
Caption Property
lblName
Name:
lblStreet
Street:
lblCity
City:
lblState
State:
lblZip
Zip:

 
< previous page page_308 next page >